Skip to main content

Bug Tracker

Side navigation

Ticket #3355: stopImmediatePropagation[5843].diff
File stopImmediatePropagation[5843].diff, 1.6 KB (added by flesler, September 10, 2008 09:35PM UTC)

Uses the expando to modify the event objects, doesn't break old code.

Index: src/event.js
===================================================================
--- src/event.js	(revision 5843)
+++ src/event.js	(working copy)
@@ -190,6 +190,7 @@
 					target: elem,
 					preventDefault: function(){},
 					stopPropagation: function(){},
+					stopImmediatePropagation:stopImmediatePropagation,
 					timeStamp: now()
 				});
 				data[0][expando] = true; // no need to fix fake event
@@ -271,6 +272,13 @@
 					event.preventDefault();
 					event.stopPropagation();
 				}
+
+				if( event[expando] == -1 ){
+					event[expando] = true;
+					break;
+				}
+
+				
 			}
 		}
 
@@ -280,7 +288,7 @@
 	props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" "),
 
 	fix: function(event) {
-		if ( event[expando] == true )
+		if ( event[expando] )
 			return event;
 
 		// store a copy of the original event object
@@ -313,6 +321,8 @@
 			originalEvent.cancelBubble = true;
 		};
 
+		event.stopImmediatePropagation = stopImmediatePropagation;
+
 		// Fix timeStamp
 		event.timeStamp = event.timeStamp || now();
 
@@ -367,6 +377,11 @@
 	}
 };
 
+function stopImmediatePropagation(){
+	this[expando] = -1;
+	this.stopPropagation();
+}
+
 if ( !jQuery.browser.msie ){	
 	// Checks if an event happened on an element within another element
 	// Used in jQuery.event.special.mouseenter and mouseleave handlers

Download in other formats:

Original Format